package com.wobangkj.common.repository;

import com.wobangkj.common.model.crud.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface CommentRepository extends JpaRepository<Comment, Long> {
    @Query(nativeQuery = true,value = "select s.*,u.major,u.name,u.mst_company_id,u.mst_job,u.grade,u.school,u.college,u.headimg from comment s inner join user u on s.comment_publisher_id = u.id where s.text_id= :id and s.comment_text_class=:comment_text_class ;") //原生SQL方法
    List<Map> getListById(String id,String comment_text_class);

    @Query(nativeQuery = true,value = "select s.*,u.major,u.name,u.mst_company_id,u.mst_job,u.grade,u.school,u.college,u.headimg from comment s inner join user u on s.comment_publisher_id = u.id where s.comment_parent_id= :id ;") //原生SQL方法
    List<Map> getListByParentId(long id);

    @Query(nativeQuery = true, value="select l.* ,u.name,u.headimg,u.is_master from  comment l join user u on" +
            " l.comment_publisher_id=u.id  where l.comment_reply_id=:Id ORDER BY l.createtime DESC; " )
    List<Map> findMy(String Id);

    @Query(nativeQuery = true, value="select share_id from  share  where id=:ContentId ")
    public String getSharerId(String ContentId );

    @Query(nativeQuery = true, value="select dynamic_publisher_id from  dynamic  where id=:ContentId ")
    public String getDynamicPublisherId(String ContentId );

    @Query(nativeQuery = true, value="select job_publisher_id from  job  where id=:ContentId ")
    public String getJobPublisherId(String ContentId );
}
